use chrono::{DateTime, Local};
use serde::{Deserialize, Serialize};
use std::default::Default;

pub mod config;

// 定义服务器配置
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum View {
    Dashboard,
    Servers,
    Settings,
    SpeedTest,
}

impl Default for View {
    fn default() -> Self {
        Self::Dashboard
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ServerType {
    Shadowsocks,
    Vmess,
    Trojan,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServerConfig {
    pub name: String,
    pub host: String,
    pub port: u16,
    pub server_type: ServerType,
    pub password: String,
    pub encryption: String,
}

impl Default for ServerConfig {
    fn default() -> Self {
        Self {
            name: "新服务器".to_string(),
            host: "example.com".to_string(),
            port: 8388,
            server_type: ServerType::Shadowsocks,
            password: "password".to_string(),
            encryption: "aes-256-gcm".to_string(),
        }
    }
}

// 测速结果
#[derive(Debug, Clone)]
pub struct SpeedTestResult {
    pub server_name: String,
    pub ping: f64,          // ms，负值表示超时
    pub timestamp: DateTime<Local>,
} 